<?php ob_start(); ?> 
<?php header ('Content-type: text/xml; charset=utf-8'); ?>     

<?php include "constants.inc" ?>

<?php include "classes.inc" ?>

<?php session_start(); ?> 

<?php 

function storePlayerClub($playerClub, $row) {

	if ( isset($_SESSION['user']) && isset($playerClub) && is_numeric($playerClub) == true

		&& isset($_SESSION['players']) && isset($row) ) {



        $user = $_SESSION['user'];

        $players = $_SESSION['players'];

        $player = $players[$row-1];



        if (empty($player->player_key)) {

            $connect = mysql_connect(DB_SERVER, DB_USER, DB_PWD);

        	mysql_select_db(DB_CATALOG);

	        $result = mysql_query("select club_id from club where club_id = ".$playerClub);

	        if (mysql_num_rows($result) > 0) {

                $player->club_id = $playerClub;

            	$players[$row-1] = $player;

	            $_SESSION['players'] = $players;

	            return '1';

            }

        } else {

            $connect = mysql_connect(DB_SERVER, DB_USER, DB_PWD);

			mysql_select_db(DB_CATALOG);

			$result = mysql_query("select club from playernew where matricule = ".$player->player_key);

        	$record = mysql_fetch_assoc($result);

        	if ($record['club_id'] == $playerClub) {

            	return '1';

            } else {

            	return '2';

            }

        }

    }



    return '0';

}

?>

<response>

  <method>storePlayerClub</method>

  <result><?php

    echo storePlayerClub($_GET['playerClub'], $_GET['row'])?></result>

</response>